<?php

namespace App\Admin\Controllers;

use App\Admin\Repositories\EatMessage;
use Dcat\Admin\Form;
use Dcat\Admin\Grid;
use Dcat\Admin\Show;
use Dcat\Admin\Http\Controllers\AdminController;

class EatMessageController extends AdminController
{
    /**
     * Make a grid builder.
     *
     * @return Grid
     */
    protected function grid()
    {
        return Grid::make(new EatMessage(), function (Grid $grid) {
            $grid->column('id')->sortable();
            $grid->column('open_id');
            $grid->column('str_1');
            $grid->column('str_2');
            $grid->column('str_3');
            $grid->column('str_4');
            $grid->column('str_5');
            $grid->column('str_6');
            $grid->column('str_7');
            $grid->column('str_8');
            $grid->column('str_9');
            $grid->column('str_10');
            $grid->column('str_11');
            $grid->column('str_12');
            $grid->column('created_at');
            $grid->column('updated_at')->sortable();
            $grid->export();
            $grid->filter(function (Grid\Filter $filter) {
                $filter->equal('id');
        
            });
        });
    }

    /**
     * Make a show builder.
     *
     * @param mixed $id
     *
     * @return Show
     */
    protected function detail($id)
    {
        return Show::make($id, new EatMessage(), function (Show $show) {
            $show->field('id');
            $show->field('open_id');
            $show->field('str_1');
            $show->field('str_2');
            $show->field('str_3');
            $show->field('str_4');
            $show->field('str_5');
            $show->field('str_6');
            $show->field('str_7');
            $show->field('str_8');
            $show->field('str_9');
            $show->field('str_10');
            $show->field('str_11');
            $show->field('str_12');
            $show->field('created_at');
            $show->field('updated_at');
        });
    }

    /**
     * Make a form builder.
     *
     * @return Form
     */
    protected function form()
    {
        return Form::make(new EatMessage(), function (Form $form) {
            $form->display('id');
            $form->text('open_id');
            $form->text('str_1');
            $form->text('str_2');
            $form->text('str_3');
            $form->text('str_4');
            $form->text('str_5');
            $form->text('str_6');
            $form->text('str_7');
            $form->text('str_8');
            $form->text('str_9');
            $form->text('str_10');
            $form->text('str_11');
            $form->text('str_12');
        
            $form->display('created_at');
            $form->display('updated_at');
        });
    }
}
